import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Layout",
    component: () => import("../views/layout"),
    redirect: "/home",
    children: [
      {
        path: "home",
        name: "首页",
        component: () => import("../views/home"),
      },
      {
        path: "blog",
        name: "Blog",
        component: () => import("../views/blog"),
      },
      {
        path: "rank",
        name: "Rank",
        component: () => import("../views/rank"),
      },
      {
        path: "log",
        name: "Log",
        component: () => import("../views/log"),
      },
      {
        path: "question",
        name: "Question",
        component: () => import("../views/question"),
      },
      {
        path: "message",
        name: "Message",
        component: () => import("../views/message"),
      },
      {
        path: "manage",
        name: "Manage",
        component: () => import("../views/manage"),
        children: [
          {
            path: "blogForm",
            name: "BlogForm",
            component: () => import("../views/blog/form"),
          },
          {
            path: "blogList",
            name: "BlogList",
            component: () => import("../views/blog/list"),
          },
        ]
      },
    ]
  },
  {
    path: "/register",
    name: "Register",
    component: () => import("../views/others/register"),
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("../views/others/login"),
  },
  {
    path: "/about",
    name: "About",
    component: () => import("../views/about"),
  },
  {
    path: "/404",
    name: "404",
    component: () => import("../views/others/404"),
  },
  {
    path: "*",
    redirect: "/404",
    hidden: true,
  },
];

const router = new VueRouter({
  routes,
});

export default router;
